JavaScript from Beginner to Professional by Laurence Lars Svekis & Maaike van Putten & Rob Percival

JavaScript from Beginner to Professional by Laurence Lars Svekis & Maaike van Putten & Rob Percival

Author:Laurence Lars Svekis & Maaike van Putten & Rob Percival [Laurence Lars Svekis]
Language: eng
Format: epub
Publisher: Packt Publishing
Published: 2021-12-14T16:00:00+00:00


You could also combine them:

console.dir(document.body.childNodes[3].childNodes[3].childNodes[1].children.treasure);

There are many ways to traverse the document. Depending on what you need, you might have to use one specific way. For tasks that require DOM traversing, it is usually the case that if it is works, it is a good solution.

So far, we have seen how we can move down the DOM, but we can also move up. Every element knows its parent. We can use the parentElement property to move back up. For example, if we use the treasure HTML sample and type this into the console:

document.body.children.forest.children.tree2.parentElement;



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.